home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWPxyFrm.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  19.6 KB  |  659 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPxyFrm.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWPXYFRM_H
  13. #include "FWPxyFrm.h"
  14. #endif
  15.  
  16. #ifndef FWPARTNG_H
  17. #include "FWPartng.h"
  18. #endif
  19.  
  20. #ifndef FWFRMING_H
  21. #include "FWFrming.h"
  22. #endif
  23.  
  24. #ifndef FWPROXY_H
  25. #include "FWProxy.h"
  26. #endif
  27.  
  28. #ifndef FWUTIL_H
  29. #include "FWUtil.h"
  30. #endif
  31.  
  32. #ifndef FWCLNINF_H
  33. #include "FWClnInf.h"
  34. #endif
  35.  
  36. // ----- OS Layer -----
  37.  
  38. #ifndef FWBARRAY_H
  39. #include "FWBArray.h"
  40. #endif
  41.  
  42. #ifndef FWGRUTIL_H
  43. #include "FWGrUtil.h"
  44. #endif
  45.  
  46. #ifndef FWODGEOM_H
  47. #include "FWODGeom.h"
  48. #endif
  49.  
  50. // ----- OpenDoc Includes -----
  51.  
  52. #ifndef SOM_ODFrame_xh
  53. #include <Frame.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODFacet_xh
  57. #include <Facet.xh>
  58. #endif
  59.  
  60. #ifndef SOM_Module_OpenDoc_StdProps_defined
  61. #include <StdProps.xh>
  62. #endif
  63.  
  64. #ifndef SOM_ODStorageUnitView_xh
  65. #include <SUView.xh>
  66. #endif
  67.  
  68. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  69. #include <StdTypes.xh>
  70. #endif
  71.  
  72. #ifndef SOM_ODEmbeddedFramesIterator_xh
  73. #include <EmbFrItr.xh>
  74. #endif
  75.  
  76. #ifndef SOM_ODTransform_xh
  77. #include <Trnsform.xh>
  78. #endif
  79.  
  80. #ifndef SOM_ODDraft_xh
  81. #include <Draft.xh>
  82. #endif
  83.  
  84. //========================================================================================
  85. //    RunTime Info
  86. //========================================================================================
  87.  
  88. #if FW_LIB_EXPORT_PRAGMAS
  89. #pragma lib_export on
  90. #endif
  91.  
  92. #ifdef FW_BUILD_MAC
  93. #pragma segment fw_embedding
  94. #endif
  95.  
  96. //========================================================================================
  97. //    class FW_CProxyFrame
  98. //========================================================================================
  99.  
  100. //----------------------------------------------------------------------------------------
  101. //    FW_CProxyFrame::FW_CProxyFrame
  102. //----------------------------------------------------------------------------------------
  103.  
  104. FW_CProxyFrame::FW_CProxyFrame(Environment* ev, 
  105.                             FW_CEmbeddingPart* part) :
  106.     fPart(part),
  107.     fProxy(NULL),
  108.     fFrameID(kODNULLID),
  109.     fContainingFrameID(kODNULLID),
  110.     fEmbeddedFrame(NULL),
  111.     fPurgeable(FALSE),
  112.     fAttached(TRUE)
  113. {
  114.     FW_ASSERT(fPart != NULL);
  115.     
  116.     // ----- Add it to the part -----
  117.     fPart->PrivAddProxyFrame(ev, this);
  118. }
  119.  
  120. //----------------------------------------------------------------------------------------
  121. //    FW_CProxyFrame::FW_CProxyFrame
  122. //----------------------------------------------------------------------------------------
  123.  
  124. FW_CProxyFrame::FW_CProxyFrame(Environment* ev, 
  125.                                 FW_CEmbeddingPart* part, 
  126.                                 FW_MProxy* proxy,
  127.                                 FW_CEmbeddingFrame* containingFrame, 
  128.                                 ODFrame* embeddedFrame) :
  129.     fPart(part),
  130.     fProxy(proxy),
  131.     fFrameID(kODNULLID),
  132.     fContainingFrameID(kODNULLID),
  133.     fEmbeddedFrame(embeddedFrame),
  134.     fPurgeable(FALSE),
  135.     fAttached(TRUE)
  136. {
  137.     FW_ASSERT(fPart != NULL);
  138.     FW_ASSERT(fProxy != NULL);
  139.     FW_ASSERT(containingFrame != NULL);
  140.     FW_ASSERT(fEmbeddedFrame != NULL);
  141.     FW_ASSERT(containingFrame->GetPart(ev) == part);
  142.     
  143.     fEmbeddedFrame->Acquire(ev);
  144.     fFrameID = fEmbeddedFrame->GetID(ev);
  145.     
  146.     fContainingFrameID = containingFrame->GetID(ev);
  147.  
  148. #ifdef FW_DEBUG
  149.     {
  150.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  151.         FW_ASSERT(aqContainingFrame == containingFrame->GetODFrame(ev));
  152.     }
  153. #endif
  154.  
  155.     // ----- add it to the proxy -----    
  156.     fProxy->PrivAddProxyFrame(ev, this);
  157.     
  158.     FW_TRY {
  159.         // ----- Add it to the part -----
  160.         fPart->PrivAddProxyFrame(ev, this);
  161.     
  162.         FW_TRY {
  163.             // ----- Add it to the embedding frame -----
  164.             containingFrame->PrivAddProxyFrame(ev, this);
  165.         }
  166.         FW_CATCH_BEGIN
  167.         FW_CATCH_EVERYTHING () {
  168.             fPart->PrivRemoveProxyFrame (ev, this);
  169.             FW_THROW_SAME ();
  170.         }
  171.         FW_CATCH_END
  172.     }
  173.     FW_CATCH_BEGIN
  174.     FW_CATCH_EVERYTHING () {
  175.         fProxy->PrivRemoveProxyFrame (ev, this);
  176.         FW_THROW_SAME ();
  177.     }
  178.     FW_CATCH_END
  179.     
  180.     // ----- If the frame was in Limbo -----
  181.     embeddedFrame->SetInLimbo(ev, FALSE);
  182. }
  183.  
  184. //----------------------------------------------------------------------------------------
  185. //    FW_CProxyFrame::FW_CProxyFrame
  186. //----------------------------------------------------------------------------------------
  187.  
  188. FW_CProxyFrame::FW_CProxyFrame(Environment* ev, 
  189.                                 FW_CEmbeddingPart* part, 
  190.                                 FW_MProxy* proxy,
  191.                                 ODStorageUnitID embeddedFrameID) :
  192.     fPart(part),
  193.     fProxy(proxy),
  194.     fFrameID(embeddedFrameID),
  195.     fContainingFrameID(kODNULLID),
  196.     fEmbeddedFrame(NULL),
  197.     fPurgeable(FALSE),
  198.     fAttached(TRUE)
  199. {
  200.     FW_ASSERT(fPart != NULL);
  201.     FW_ASSERT(fProxy != NULL);
  202.     FW_ASSERT(embeddedFrameID != kODNULLID);
  203.  
  204.     // ----- add it to the proxy -----    
  205.     fProxy->PrivAddProxyFrame(ev, this);
  206.     
  207.     // ----- Add it to the part -----
  208.     fPart->PrivAddProxyFrame(ev, this);
  209. }
  210.  
  211. //----------------------------------------------------------------------------------------
  212. //    FW_CProxyFrame::~FW_CProxyFrame
  213. //----------------------------------------------------------------------------------------
  214.  
  215. FW_CProxyFrame::~FW_CProxyFrame()
  216. {
  217.     if (fEmbeddedFrame)
  218.     {
  219.         Environment* ev = somGetGlobalEnvironment();
  220.         if (fEmbeddedFrame->IsInLimbo(ev))
  221.             fEmbeddedFrame->Remove(ev);
  222.         else
  223.             fEmbeddedFrame->Release(ev);
  224.     }
  225. }
  226.  
  227. //----------------------------------------------------------------------------------------
  228. //    FW_CProxyFrame::GetContainingFrame
  229. //----------------------------------------------------------------------------------------
  230. //    GetContainingFrame returns null if the containing frame of this proxyframe is not a valid 
  231. //    display frame
  232.  
  233. FW_CEmbeddingFrame* FW_CProxyFrame::GetContainingFrame(Environment* ev) const
  234. {
  235.     FW_CProxyFrame* self = (FW_CProxyFrame*)this;
  236.     
  237.     if (fPart->IsValidDisplayFrame(ev, fContainingFrameID))
  238.     {
  239.         FW_CAcquiredODFrame aqContainingODFrame =  fPart->GetStorageUnit(ev)->GetDraft(ev)->AcquireFrame(ev, fContainingFrameID);
  240.  
  241.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingODFrame);
  242.         FW_ASSERT(containingFrame != NULL);
  243.     
  244.         return containingFrame;
  245.     }
  246.     
  247.     return NULL;
  248. }
  249.  
  250. //----------------------------------------------------------------------------------------
  251. //    FW_CProxyFrame::GetFrame
  252. //----------------------------------------------------------------------------------------
  253.  
  254. ODFrame* FW_CProxyFrame::GetFrame(Environment* ev) const
  255. {
  256.     if (fEmbeddedFrame == NULL)
  257.     {
  258.         FW_CProxyFrame* self = (FW_CProxyFrame*)this;
  259.         
  260.         self->fEmbeddedFrame = fPart->GetStorageUnit(ev)->GetDraft(ev)->AcquireFrame(ev, fFrameID);
  261.         if (fAttached)
  262.             fEmbeddedFrame->SetInLimbo(ev, FALSE);    // Just in case
  263.             
  264.         FW_ASSERT(fEmbeddedFrame != NULL);
  265.     }
  266.     
  267.     return fEmbeddedFrame;
  268. }
  269.  
  270. //----------------------------------------------------------------------------------------
  271. //    FW_CProxyFrame::IsVisible
  272. //----------------------------------------------------------------------------------------
  273.  
  274. FW_Boolean FW_CProxyFrame::IsVisible(Environment* ev, ODFacet* containingFacet, const FW_CRect& bounds) const
  275. {
  276.     FW_CAcquiredODShape aqClipShape = containingFacet->AcquireClipShape(ev, NULL);
  277.     FW_CRect clipRect = FW_GetShapeBoundingBox(ev, aqClipShape);
  278.     
  279.     FW_CAcquiredODTransform aqInternalTransform = containingFacet->GetFrame(ev)->AcquireInternalTransform(ev, NULL);
  280.     FW_CRect tempRect = bounds.TransformCopy(ev, aqInternalTransform);
  281.     
  282.     if (clipRect.IsIntersecting(tempRect))
  283.         return TRUE;
  284.     
  285.     return FALSE;
  286. }
  287.  
  288. //----------------------------------------------------------------------------------------
  289. //    FW_CProxyFrame::SetPurgeable
  290. //----------------------------------------------------------------------------------------
  291.  
  292. void FW_CProxyFrame::SetPurgeable(Environment* ev, FW_Boolean purgeable)
  293. {
  294.     fPurgeable = purgeable;
  295.     
  296.     if (!fPurgeable)
  297.     {
  298.         FW_Boolean wasInMemory = IsFrameInMemory(ev);
  299.         
  300.         GetFrame(ev);    // to be sure that the frame is in memory
  301.  
  302.         // ----- Create facets for the new frame if it was not in memory-----
  303.         if (!wasInMemory)
  304.         {
  305.             FW_ASSERT(fPart->IsValidDisplayFrame(ev, fContainingFrameID));
  306.             GetContainingFrame(ev)->PrivCreateEmbeddedFacets(ev, fProxy, this);
  307.         }
  308.     }
  309. }
  310.  
  311. //----------------------------------------------------------------------------------------
  312. //    FW_CProxyFrame::Close
  313. //----------------------------------------------------------------------------------------
  314.  
  315. void FW_CProxyFrame::Close(Environment* ev)
  316. {
  317.     // if fEmbeddedFrame == NULL it is already closed
  318.     if (fEmbeddedFrame == NULL)
  319.         return;
  320.  
  321.     // ----- Close the frame -----
  322.     fEmbeddedFrame->Close(ev);        // Will call release    
  323.     fEmbeddedFrame = NULL;
  324. }
  325.  
  326. //----------------------------------------------------------------------------------------
  327. //    ExternalizeInScope
  328. //----------------------------------------------------------------------------------------
  329.  
  330. static void ExternalizeInScope(Environment* ev, ODPart* thePart, ODFrame* scopeFrame)
  331. {
  332.     ODEmbeddedFramesIterator* ite = thePart->CreateEmbeddedFramesIterator(ev, scopeFrame);
  333.     for (ODFrame* embeddedFrame = ite->First(ev); ite->IsNotComplete(ev); embeddedFrame = ite->Next(ev))
  334.     {
  335.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  336.         if (aqContainingFrame == scopeFrame)
  337.         {
  338.             FW_CAcquiredODPart aqEmbeddedPart = embeddedFrame->AcquirePart(ev);
  339.  
  340.             embeddedFrame->Externalize(ev);
  341.             aqEmbeddedPart->Externalize(ev);
  342.             
  343.             ExternalizeInScope(ev, aqEmbeddedPart, embeddedFrame);
  344.         }
  345.     }
  346.     
  347.     delete ite;
  348. }
  349.  
  350. //----------------------------------------------------------------------------------------
  351. //    FW_CProxyFrame::Purge
  352. //----------------------------------------------------------------------------------------
  353.  
  354. ODSize FW_CProxyFrame::Purge(Environment* ev)
  355. {
  356.     if (!IsFrameInMemory(ev))
  357.         return 0;                // already gone
  358.         
  359.     // [HLX] I am not sure about that. If purge is called in a middle of a drag&drop I
  360.     // may not be the owner of this frame anymore ????
  361.     FW_CAcquiredODFrame aqODContainingFrame = fEmbeddedFrame->AcquireContainingFrame(ev);
  362.     FW_CAcquiredODPart aqODContainingPart = aqODContainingFrame->AcquirePart(ev);
  363.     if (aqODContainingPart != fPart->GetODPart(ev))
  364.         fPurgeable = FALSE;
  365.     
  366.     if (fPurgeable)
  367.     {
  368.         // ----- HLX] OpenDoc Bug????
  369.         fEmbeddedFrame->Externalize(ev);
  370.         FW_CAcquiredODPart aqEmbeddedPart = fEmbeddedFrame->AcquirePart(ev);
  371.         aqEmbeddedPart->Externalize(ev);
  372.         ExternalizeInScope(ev, aqEmbeddedPart, fEmbeddedFrame);
  373.         // ----- [HLX] OpenDoc Bug????
  374.         
  375.         // ----- Remove its facets
  376.         FW_ASSERT(fPart->IsValidDisplayFrame(ev, fContainingFrameID));
  377.         GetContainingFrame(ev)->PrivRemoveEmbeddedFacets(ev, this);
  378.     
  379.         // ----- Now I can close the frame
  380.         Close(ev);
  381.     }
  382.     
  383.     return 0;  // [HLX] need to be able to get the size of what I am releasing
  384. }
  385.  
  386. //----------------------------------------------------------------------------------------
  387. //    FW_CProxyFrame::InternalizeProxyFrame
  388. //----------------------------------------------------------------------------------------
  389. //    returns true if valid 
  390.  
  391. FW_Boolean FW_CProxyFrame::InternalizeProxyFrame(Environment* ev, ODStorageUnitView* suView, FW_CCloneInfo* cloneInfo)
  392. {
  393.     ODStorageUnitRef aSURef;
  394.     
  395.     FW_CByteArray byteArray;
  396.     suView->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
  397.     byteArray.CopyBuffer(&aSURef, sizeof(ODStorageUnitRef));
  398.     
  399.     if (!suView->IsValidStorageUnitRef(ev, aSURef))
  400.         return FALSE;
  401.     
  402.     ODStorageUnitID fromFrameID = suView->GetIDFromStorageUnitRef(ev, aSURef);
  403.  
  404.     if (cloneInfo != NULL)
  405.     {
  406.         // ----- We are cloning -----
  407.         fFrameID = cloneInfo->Clone(ev, fromFrameID, 0, 0);
  408.         fContainingFrameID = cloneInfo->GetScopeFrame(ev)->GetID(ev);
  409.     }
  410.     else
  411.     {
  412.         // ----- We are just reading -----
  413.         fFrameID = fromFrameID;
  414.         
  415.         // ----- Cache the id of the containing frame -----
  416.         FW_CAcquiredODStorageUnit aqFrameSU = suView->GetStorageUnit(ev)->GetDraft(ev)->AcquireStorageUnit(ev, fFrameID);
  417.         aqFrameSU->Focus(ev, kODPropContainingFrame, kODPosUndefined, kODWeakStorageUnitRef, 0, kODPosUndefined);
  418.         
  419.         aqFrameSU->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
  420.         byteArray.CopyBuffer(&aSURef, sizeof(ODStorageUnitRef));
  421.  
  422.         if (aqFrameSU->IsValidStorageUnitRef(ev, aSURef))
  423.             fContainingFrameID = aqFrameSU->GetIDFromStorageUnitRef(ev, aSURef);
  424.         else
  425.             fContainingFrameID = kODNULLID;
  426.     }
  427.     
  428.     return TRUE;
  429. }
  430.  
  431. //----------------------------------------------------------------------------------------
  432. //    FW_CProxyFrame::ExternalizeProxyFrame
  433. //----------------------------------------------------------------------------------------
  434.  
  435. FW_Boolean FW_CProxyFrame::ExternalizeProxyFrame(Environment* ev, ODStorageUnitView* suView, FW_CCloneInfo* cloneInfo)
  436. {
  437.     FW_ASSERT(fPart->IsValidDisplayFrame(ev, fContainingFrameID));
  438.  
  439.     FW_Boolean externalize = FALSE;
  440.     ODStorageUnitID frameID = fFrameID;
  441.  
  442.     if (cloneInfo != NULL)
  443.     {
  444.         if (cloneInfo->GetScopeFrame(ev) == NULL)
  445.             externalize = GetContainingFrame(ev)->IsPersistent(ev);    // Only clone frames with a persistent containing Frame
  446.         else
  447.             externalize = (cloneInfo->GetScopeFrame(ev)->GetID(ev) == fContainingFrameID);
  448.         
  449.         if (externalize)
  450.             frameID = cloneInfo->Clone(ev, fFrameID, 0, fFrameID);
  451.     }
  452.     else
  453.     {
  454.         // We only externalize frame that have a persistent containing Frame
  455.         externalize = GetContainingFrame(ev)->IsPersistent(ev);
  456.     }
  457.     
  458.     if (externalize)
  459.     {
  460.         ODStorageUnitRef aSURef;
  461.     
  462.         // ----- Write out the embedded frame reference -----
  463.         FW_CByteArray byteArray(&aSURef, sizeof(ODStorageUnitRef));
  464.          suView->GetStrongStorageUnitRef(ev, frameID, aSURef);
  465.         suView->SetValue(ev, byteArray);
  466.     }
  467.     
  468.     return externalize;
  469. }
  470.  
  471. //----------------------------------------------------------------------------------------
  472. //    FW_CProxyFrame::SetProxy
  473. //----------------------------------------------------------------------------------------
  474.  
  475. void FW_CProxyFrame::SetProxy(Environment* ev, FW_MProxy* proxy)
  476. {
  477.     FW_ASSERT(fProxy == NULL || proxy == NULL || fProxy == proxy);
  478.     fProxy = proxy;
  479. }
  480.  
  481. //----------------------------------------------------------------------------------------
  482. //    FW_CProxyFrame::SetContainingFrame
  483. //----------------------------------------------------------------------------------------
  484. // We can't change the containing frame is this proxyframe is not orphaned
  485.  
  486. void FW_CProxyFrame::SetContainingFrame(Environment* ev, FW_CEmbeddingFrame* containingFrame)
  487. {
  488.     FW_ASSERT(IsOrphan(ev));
  489.     fContainingFrameID = containingFrame->GetID(ev);
  490.     
  491.     ODFrame* embeddedFrame = GetFrame(ev);    // Need to bring it into memory
  492.     embeddedFrame->SetContainingFrame(ev, containingFrame->GetODFrame(ev));
  493. }
  494.  
  495. //----------------------------------------------------------------------------------------
  496. //    FW_CProxyFrame::HasASelectedFacet
  497. //----------------------------------------------------------------------------------------
  498.  
  499. FW_Boolean FW_CProxyFrame::HasASelectedFacet(Environment* ev) const
  500. {
  501.     return fProxy->GetSelectState(ev);
  502. }
  503.  
  504. //----------------------------------------------------------------------------------------
  505. //    FW_CProxyFrame::PrivAttach
  506. //----------------------------------------------------------------------------------------
  507.  
  508. void FW_CProxyFrame::PrivAttach(Environment* ev)
  509. {
  510.     FW_CEmbeddingFrame* embeddingFrame = GetContainingFrame(ev);
  511.     if (embeddingFrame != NULL && !fAttached)    
  512.     {
  513.         // [HLX] I have to load the frame. Is this a problem?
  514.         ODFrame* odEmbeddedFrame = GetFrame(ev);
  515.     
  516.         // ----- Add it from the part -----
  517.         fPart->PrivAddProxyFrame(ev, this);
  518.             
  519.         odEmbeddedFrame->SetContainingFrame(ev, embeddingFrame->GetODFrame(ev));
  520.         odEmbeddedFrame->SetInLimbo(ev, FALSE);
  521.  
  522.         // ----- Add it to the embedding frame -----
  523.         embeddingFrame->PrivAddProxyFrame(ev, this);
  524.         
  525.         // ----- It is now attached -----
  526.         fAttached = TRUE;
  527.     
  528.         // ----- Create the facets -----
  529.         embeddingFrame->PrivCreateEmbeddedFacets(ev, fProxy, this);
  530.     }
  531. }
  532.  
  533. //----------------------------------------------------------------------------------------
  534. //    FW_CProxyFrame::PrivDetach
  535. //----------------------------------------------------------------------------------------
  536.  
  537. void FW_CProxyFrame::PrivDetach(Environment* ev)
  538. {
  539.     FW_CEmbeddingFrame* embeddingFrame = GetContainingFrame(ev);
  540.     if (embeddingFrame != NULL && fAttached)
  541.     {
  542.         embeddingFrame->PrivRemoveEmbeddedFacets(ev, this);
  543.     
  544.         // [HLX] I have to load the frame. Is this a problem?
  545.         ODFrame* odEmbeddedFrame = GetFrame(ev);
  546.     
  547.         // ----- Remove it from the embedding frame -----
  548.         embeddingFrame->PrivRemoveProxyFrame(ev, this);
  549.         
  550.         // ----- Set the containing frame to null -----
  551.         FW_CAcquiredODFrame aqODContainingFrame = odEmbeddedFrame->AcquireContainingFrame(ev);
  552.         if (aqODContainingFrame == embeddingFrame->GetODFrame(ev))
  553.         {
  554.             odEmbeddedFrame->SetInLimbo(ev, TRUE);
  555.             odEmbeddedFrame->SetContainingFrame(ev, NULL);
  556.         }
  557.                 
  558.         // ----- Remove it from the part -----
  559.         fPart->PrivRemoveProxyFrame(ev, this);
  560.     
  561.         // ----- It is now detached -----
  562.         fAttached = FALSE;
  563.     }
  564.     
  565.     FW_ASSERT(GetRefCount() == 1);
  566. }
  567.  
  568. //----------------------------------------------------------------------------------------
  569. //    PrivAcquireProxyFrame
  570. //----------------------------------------------------------------------------------------
  571. //    Called from FW_CEmbeddingPart, FW_CEmbeddingFrame and FW_MProxy::PrivAcquireProxyFrame
  572.  
  573. FW_CProxyFrame* FW_CProxyFrame::PrivAcquireProxyFrame(Environment* ev, FW_CPrivOrderedCollection* proxyFrames, ODStorageUnitID frameID)
  574. {
  575.     FW_COrderedCollectionIterator ite(proxyFrames);
  576.     for (FW_CProxyFrame* proxyFrame = (FW_CProxyFrame*)ite.First(); ite.IsNotComplete(); proxyFrame = (FW_CProxyFrame*)ite.Next())
  577.     {
  578.         if (frameID == proxyFrame->GetFrameID(ev))
  579.         {
  580.             proxyFrame->Acquire();
  581.             return proxyFrame;
  582.         }
  583.     }
  584.     
  585.     return NULL;
  586. }
  587.  
  588. //========================================================================================
  589. //    class FW_CAcquiredProxyFrame
  590. //========================================================================================
  591.  
  592. //----------------------------------------------------------------------------------------
  593. // FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame
  594. //----------------------------------------------------------------------------------------
  595.  
  596. FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame() :
  597.     fProxyFrame(NULL)
  598. {
  599.     FW_END_CONSTRUCTOR
  600. }
  601.  
  602. //----------------------------------------------------------------------------------------
  603. // FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame
  604. //----------------------------------------------------------------------------------------
  605.  
  606. FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame(FW_CProxyFrame* proxyFrame) :
  607.     fProxyFrame(proxyFrame)
  608. {
  609.     FW_END_CONSTRUCTOR
  610. }
  611.  
  612. //----------------------------------------------------------------------------------------
  613. // FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame
  614. //----------------------------------------------------------------------------------------
  615.  
  616. FW_CAcquiredProxyFrame::FW_CAcquiredProxyFrame(const FW_CAcquiredProxyFrame& other) :
  617.     fProxyFrame(other.fProxyFrame)
  618. {
  619.     fProxyFrame->Acquire();
  620.     FW_END_CONSTRUCTOR
  621. }
  622.  
  623. //----------------------------------------------------------------------------------------
  624. // FW_CAcquiredProxyFrame::~FW_CAcquiredProxyFrame
  625. //----------------------------------------------------------------------------------------
  626.  
  627. FW_CAcquiredProxyFrame::~FW_CAcquiredProxyFrame()
  628. {
  629.     FW_START_DESTRUCTOR
  630.     
  631.     if (fProxyFrame)
  632.         fProxyFrame->Release();
  633. }
  634.  
  635. //----------------------------------------------------------------------------------------
  636. // FW_CAcquiredProxyFrame::operator=
  637. //----------------------------------------------------------------------------------------
  638.  
  639. FW_CAcquiredProxyFrame& FW_CAcquiredProxyFrame::operator=(FW_CProxyFrame* proxyFrame)
  640. {
  641.     if (fProxyFrame)
  642.         fProxyFrame->Release();
  643.     fProxyFrame = proxyFrame;
  644.     return *this;    
  645. }
  646.  
  647. //----------------------------------------------------------------------------------------
  648. // FW_CAcquiredProxyFrame::operator=
  649. //----------------------------------------------------------------------------------------
  650.  
  651. FW_CAcquiredProxyFrame& FW_CAcquiredProxyFrame::operator=(const FW_CAcquiredProxyFrame& other)
  652. {
  653.     if (fProxyFrame)
  654.         fProxyFrame->Release();
  655.     fProxyFrame = other.fProxyFrame;
  656.     fProxyFrame->Acquire();
  657.     return *this;    
  658. }
  659.